package com.example.myapplication;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.myapplication.databinding.DashboardFragmentBinding;
import com.example.myapplication.databinding.FragmentDashboardChildBinding;

import java.text.MessageFormat;


public class DashboardChildFragment extends Fragment {

    private static final String ARGUMENT_POSITION ="argument_position";
    private FragmentDashboardChildBinding binding;


    public DashboardChildFragment() {

    }

    public static DashboardChildFragment newInstance(int position) {
        DashboardChildFragment fragment = new DashboardChildFragment();
        Bundle args = new Bundle();
        args.putInt(ARGUMENT_POSITION, position);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(@NonNull  LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        binding = FragmentDashboardChildBinding.inflate(inflater,container,false);
        return binding.getRoot();
    }

    public void onViewCreated(@NonNull View view,@NonNull Bundle savedInstanceState){
        super.onViewCreated(view,savedInstanceState);
        if(getArguments()!=null){
            int position = getArguments().getInt(ARGUMENT_POSITION);
            binding.tvDashboard.setText(MessageFormat.format("{0}{1}",getString(R.string.title_dashboard),position));
        }
    }
}